<template>
    <div class="tenant-info">
        <Form ref="adminData" :model="adminInfo" :rules="adminValidate" action="javascript:void(0)">
            <FormItem label="名称" prop="shopname">
                <Input v-model="adminInfo.shopname" placeholder="输入名称..."></Input>
            </FormItem>
            <FormItem label="手机号">
                <Input v-model="adminInfo.phone" placeholder="输入手机号..."></Input>
            </FormItem>
            <FormItem>
                <Button type="primary" @click="handleSubmit('adminData')">提交</Button>
            </FormItem>
        </Form>
    </div>
</template>


<script>
export default {
    name: 'TenantInfo',
    data() {
        return {
        adminInfo: {
            shopname: '',
            phone: '',
        },
        adminValidate: {
            shopname: [
                { required: true, message: '名称必须填写', trigger: 'blur' }
            ]
        }
        }
    },
    created: function() {
        this.getInfo();
    },
    methods: {
        handleSubmit(name) {
            this.$refs[name].validate((valid) => {
                if (valid) {
                    var params = this.adminInfo;
                    params.admin_id = this.$store.getters.user_id;
                    this.$api.login.tinfo(params).then(res => {
                        if (res.code == 200) {
                            this.$Message.success('修改成功...');
                        }
                    });
                }
            })
        },
        getInfo: function() {
            this.$api.login.detail().then(res => {
                if (res.code == 200) {
                    this.adminInfo = res.result
                }
            });
        }

    }
}
</script>
